﻿@{
    ViewBag.Title = ViewData["SiteName"] + " - " + ViewData["PageTitle"];
    Layout = "~/RazorThemes/Default/Views/Shared/_Layout.cshtml";

    bool isEmailReset = bool.Parse(ViewBag.IsEmailReset.ToString());
    bool isValid = bool.Parse(ViewBag.IsValid.ToString());
}

<div class="contentpage-outerdiv">
    <h2>Change Password</h2>
    <p>
        Use the form below to change your password.
    </p>
    <p>
        New passwords are required to be a minimum of @Html.Encode(ViewData["PasswordLength"]) characters in length.
    </p>
    <span class="field-validation-error">
    @{
        var changePwdGuid = string.Empty;
        if (!isValid)
        {
            @Html.ValidationSummary("Password change was unsuccessful. Please correct the errors and try again.")
        }
        else
        {
            if (Session["APC_Guid"]!=null) 
            {
                changePwdGuid = Session["APC_Guid"].ToString();
            }
            else if (Session["EPC_Guid"] != null)
            {
                changePwdGuid = Session["EPC_Guid"].ToString();
            }
            @Html.ValidationSummary()
        }
    }
    </span>
    @using (Html.BeginForm("changepassword", "account", FormMethod.Post, new { autocomplete = "off" }))
    {
        <div>
            <fieldset>
                <legend>Account Information</legend>
                @if (!isEmailReset)
                {
                <p>
                    <label for="currentPassword">Current password:</label>
                    @Html.Password("currentPassword")
                    @Html.ValidationMessage("currentPassword")
                </p>
                }
                <p>
                    <label for="newPassword">New password:</label>
                    @Html.Password("newPassword")
                    @Html.ValidationMessage("newPassword")
                </p>
                <p>
                    <label for="confirmPassword">Confirm new password:</label>
                    @Html.Password("confirmPassword")
                    @Html.ValidationMessage("confirmPassword")
                </p>
                <p>
                    <input type="submit" value="Change Password" />
                </p>
            </fieldset>
        </div>
        if (!string.IsNullOrEmpty(changePwdGuid))
        {
            @Html.Hidden("ChangePwdGuid", changePwdGuid)
        }
    }
</div>

